package com.example.day6.View;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;

import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.map.BaiduMapOptions;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.SupportMapFragment;
import com.example.day6.R;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

    private ViewPager main_vp;
    private TabLayout main_tab;
    private FragmentManager fm;
    private SupportMapFragment smf;
    private Fragment fragmentB;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();


    }

    private void initView() {
        main_vp = (ViewPager) findViewById(R.id.main_vp);
        main_tab = (TabLayout) findViewById(R.id.main_tab);

        main_tab.setupWithViewPager(main_vp);

        fm = getSupportFragmentManager();


        BaiduMapOptions baiduMapOptions = new BaiduMapOptions();
        baiduMapOptions.mapType(BaiduMap.MAP_TYPE_SATELLITE);

        smf = SupportMapFragment.newInstance(baiduMapOptions);
//        fragmentB = new FragmentB();

        ArrayList<Fragment> list = new ArrayList<>();
        list.add(new FragmentA());
        list.add(smf);



        ArrayList<String> tab = new ArrayList<>();
        tab.add("主页");
        tab.add("菜单");

        VpAdapter adapter = new VpAdapter(getSupportFragmentManager(), list, tab);
        main_vp.setAdapter(adapter);

    }
}
